package ddemo.service;

import ddemo.dao.AskMapper;
import ddemo.dao.CbookingMapper;
import ddemo.factory.MapperProxyFactory;
import ddemo.pojo.Cbooking;
import ddemo.pojo.User;

import java.util.List;

public class CbookService {
    private static CbookingMapper cbookingMapper = MapperProxyFactory.getMapper(CbookingMapper.class);

    public static List<Cbooking> getAll(){
        return cbookingMapper.getAll();
    }

    public static int book(Integer id, User user,String time) {
        String usestatus ="已预约";
        return cbookingMapper.book(user.getId(),usestatus,id,time);
    }

    public static int addBook(String id, Integer chargerid, String time) {
        String usestatus ="可用";
        return cbookingMapper.addBook(Integer.parseInt(id),usestatus,chargerid,time,0);
    }

    public static void deleteBook(String id, String time) {
        cbookingMapper.deleteBook(Integer.parseInt(id),time);
    }
}
